package mid

func GetGoodIndices(variables [][]int, target int) []int {
	var result []int
	for i := 0; i < len(variables); i++ {
		temp := variables[i]
		if powMod(powMod(temp[0], temp[1], 10), temp[2], temp[3]) == target {
			result = append(result, i)
		}
	}
	return result
}
func powMod(x, y, mode int) int {
	res := 1
	for y > 0 {
		if y%2 == 1 {
			res = res * x % mode
		}
		x = x * x % mode
		y /= 2
	}
	return res
}
